// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import ElementUi from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import '@/styles/index.scss'

Vue.use(ElementUi)

Vue.config.productionTip = false
// 路由拦截
router.beforeEach((to, from, next) => {
  // if (localStorage.getItem('mytoken')) {
  //   next()
  // } else {
  //   if (to.path !== '/login') {
  //     next({path: '/login'})
  //   } else {
  //     next()
  //   }
  // }
  if (to.path !== '/login') {
    if (localStorage.getItem('mytoken')) {
      next()
    } else {
      next({path: '/login'})
    }
  } else {
    next()
  }
})
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
